<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>笔试题管理</title>
		<script src="js/global.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var arr=new Array;
			$(function(){
				$.post("http://127.0.0.1:8080/findLeixing", {
				}, function(res) {
					arr=res;
				});	
				zengjia1();
				init();
			})
			function leixingn(value, row, index){
				
				for (var i=0;i<=arr.length;i++){
					if(value==arr[i].lid){
						return arr[i].lname;
					}
				}
			}
			function init(){
				var kyisel  = $("#kyisel" ).combobox('getValue');
					if(kyisel=="--请选择--"){
						kyisel=0;
					}
					var kersel  = $("#kersel" ).combobox('getValue');
					if(kersel=="--请选择--"){
						kersel=0;
					}
				
				$('#tabProfes').datagrid({    
				    url:'http://127.0.0.1:8080/findAllKaoti',    
				    method:"post",
				    pagination:true,
				    striped:true,
				    toolbar:"#tb",
				    queryParams:{
						kYi:kyisel,
						kEr:kersel,
					}
			   });
			   $("#tb").form("reset");
			}
			function caozuo(value,row,index){
				return "<a href='javascript:void(0)' onclick='upd("+index+")' class='easyui-linkbutton'>修改</a>   <a href='javascript:void(0)' onclick='del("+index+")' class='easyui-linkbutton'>删除</a>"
			}
			//增加新题
			function zengjia1(){
				$('#kyisel').combobox({    
				    url:'http://127.0.0.1:8080/findBylFather?lFather=0',    
				    valueField:'lid',    
				    textField:'lname',
				    onChange:function(newValue, oldValue){
				    	$('#kersel').combobox({    
						    url:'http://127.0.0.1:8080/findBylFather?lFather='+newValue,    
						    valueField:'lid',    
						    textField:'lname',
						});  
				    	
				    }
				});  
			}
			function zengjia(){
				$("#insert_window").window("open"); 
				$('#kyiadd').combobox({    
				    url:'http://127.0.0.1:8080/findBylFather?lFather=0',    
				    valueField:'lid',    
				    textField:'lname',
				    onChange:function(newValue, oldValue){
				    	$('#keradd').combobox({    
						    url:'http://127.0.0.1:8080/findBylFather?lFather='+newValue,    
						    valueField:'lid',    
						    textField:'lname',
						});  
				    	
				    }
				});  
			}
			function addjigouquxiao(){
				$("#insert_window").window("close");
			}
			function addbaocun(){
					var kyiadd  = $("#kyiadd" ).combobox('getValue');
					if(kyiadd=="--请选择--"){
						kyiadd=0;
					}
					var keradd  = $("#keradd" ).combobox('getValue');
					if(keradd=="--请选择--"){
						keradd=0;
					}
					var kzhengadd  = $("#kzhengadd" ).combobox('getValue');
					if(kzhengadd=="--请选择--"){
						kzhengadd=0;
					}
				$.post(
					"http://127.0.0.1:8080/saveKaoti", {
						kYi:kyiadd,
						kEr:keradd,
						kEmp:globalData.getEmpeName(),
						kDate:$("#kdateadd").datebox('getValue'),
						kTigan:$("#ktiganadd").val(),
						kA:$("#kaadd").val(),
						kB:$("#kbadd").val(),
						kC:$("#kcadd").val(),
						kD:$("#kdadd").val(),
						kE:$("#keadd").val(),
						kZheng:kzhengadd,
						kChu:$("#kchuadd").val()
					},
					function(res) {
						if(res>0) {
							alert("增加成功"); 
							$("#insert_window").window("close");
							$("#tabProfes").datagrid("reload");
						}
					}, "json");
				
				
			}
			//修改
			function upd(index){
				var data = $("#tabProfes").datagrid("getData");
				var row = data.rows[index]; 
				$("#updatejigouForm").form("load", row); 
				$("#updatejigou_window").window("open"); 
			}
		</script>
	</head>
	<body>
		<form id="tb">
			<td>试题一级</td>
			<td><input id="kyisel" style="width:80px;"  class="easyui-combobox"  name="dept" value="--请选择--"></td>
			<td>试题二级</td>
			<td><input id="kersel" style="width:80px;" class="easyui-combobox"  name="dept" value="--请选择--"></td>
					
			<a  href="javascript:void(0)" onclick="init()" class="easyui-linkbutton">查找</a>  	
			<a  href="javascript:void(0)" onclick="zengjia()" class="easyui-linkbutton">增加新题</a>  	
		</form>
		<table id="tabProfes" class="easyui-datagrid" >
			<thead>
				<tr>
					<th data-options="field:'kid',title:'序号',hidden:true,align:'center'"></th>
					<th data-options="field:'ktigan',title:'体干'"></th>
					<th data-options="field:'kyi',title:'一级分类',formatter:leixingn"></th>
					<th data-options="field:'ker',title:'二级分类',formatter:leixingn"></th>
					<th data-options="field:'kemp',title:'登记人 '"></th>
					<th data-options="field:'kdate',title:'登记时间'"></th>
					<th data-options="field:'kchu',title:'出处'"></th>
					<th data-options="field:'kzheng',title:'正确答案'"></th>
				<!--	<th data-options="field:'caozuo',title:'操作',align:'center',formatter:caozuo"></th>-->
				</tr>
			</thead>
		</table>
	</body>
	<div id="insert_window" class="easyui-window" title="增加新的机构" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:1000px;height:400px;padding:10px;">
			<table>
				<tr>
					<td>试题一级</td>
					<td><input id="kyiadd" style="width:80px;"  class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>试题二级</td>
					<td><input id="keradd" style="width:80px;" class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>登记人</td>
					<td><input id="kempadd"  style="width:80px;" name="kempadd" > </td>
					<td>登记时间</td>
					<td>
					<input  id="kdateadd" type= "text" class= "easyui-datebox" style="width:80px;">
					</td>
				</tr>
				<tr>
					<td>体干</td>
					<td colspan="7"><input  type="text"  id="ktiganadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案A</td>
					<td colspan="7"><input  type="text"  id="kaadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案B</td>
					<td colspan="7"><input  type="text"  id="kbadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案C</td>
					<td colspan="7"><input  type="text"  id="kcadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案D</td>
					<td colspan="7"><input  type="text"  id="kdadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案E</td>
					<td colspan="7"><input  type="text"  id="keadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>正确答案</td>
					<td>
						<select id="kzhengadd" class="easyui-combobox" name="kzhengadd" style="width:84px;">  
								<option value="">--请选择--</option>  
								<option value="a">A</option>
	                            <option value="b">B</option>
	                            <option value="c">C</option>
	                            <option value="d">D</option>
	                            <option value="e">E</option>
						</select> 
					</td>
					<td>试题出处</td>
					<td><input id="kchuadd" style="width:80px;"   name="kchuadd" </td>
					<td></td>
					<td></td>
					<td></td>
					<td>
					</td>
				</tr>
				<tr>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="addbaocun()">保存</a></th>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="addjigouquxiao()">取消</a></th>
				</tr>
			</table>
		</div>	
		<!--<div id="updatejigou_window" class="easyui-window" title="修改机构信息" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:400px;height:330px;padding:10px;">
			<form id="updatejigouForm">
				<table>
				<tr>
					<td>试题一级</td>
					<td><input id="kyiadd" style="width:80px;"  class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>试题二级</td>
					<td><input id="keradd" style="width:80px;" class="easyui-combobox"  name="dept" value="--请选择--"></td>
					<td>登记人</td>
					<td><input id="kempadd"  style="width:80px;" name="kempadd" > </td>
					<td>登记时间</td>
					<td>
					<input  id="kdateadd" type= "text" class= "easyui-datebox" style="width:80px;">
					</td>
				</tr>
				<tr>
					<td>体干</td>
					<td colspan="7"><input  type="text"  id="ktiganadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案A</td>
					<td colspan="7"><input  type="text"  id="kaadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案B</td>
					<td colspan="7"><input  type="text"  id="kbadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案C</td>
					<td colspan="7"><input  type="text"  id="kcadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案D</td>
					<td colspan="7"><input  type="text"  id="kdadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>答案E</td>
					<td colspan="7"><input  type="text"  id="keadd" style="width:560px;"></td>
					
				</tr>
				<tr>
					<td>正确答案</td>
					<td>
						<select id="kzhengadd" class="easyui-combobox" name="kzhengadd" style="width:84px;">  
								<option value="">--请选择--</option>  
								<option value="a">A</option>
	                            <option value="b">B</option>
	                            <option value="c">C</option>
	                            <option value="d">D</option>
	                            <option value="e">E</option>
						</select> 
					</td>
					<td>试题出处</td>
					<td><input id="kchuadd" style="width:80px;"   name="kchuadd" </td>
					<td></td>
					<td></td>
					<td></td>
					<td>
					</td>
				</tr>
				<tr>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" type="button" onclick="addbaocun()">保存</a></th>
					<th><a href="javascript:void(0)" class="easyui-linkbutton" onclick="addjigouquxiao()">取消</a></th>
				</tr>
			</table>
			</form>
		</div>	-->
</html>
